<template>
  <section>
    <Header :leftArrow="true" title="课程管理" roles="addCourse" @search="search"/>
    <form v-show="isShowSearchInput" class="form-tag" action="/">
      <van-search
        v-model="kwds"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
      />
    </form>
    <section class="course">
      <div class="course-content-wrapper">
        <div class="course-content">
          <ul>
            <CourseList />
          </ul>
        </div>
      </div>
    </section>
  </section>
</template>

<script>
import BScroll from 'better-scroll'
import Header from './../../components/Header/LeftArrowHeader'
import CourseList from './components/CourseList'

export default {
  name: 'CourseControl',
  components: {
    Header,
    CourseList
  },
  data() {
    return {
      kwds: '', // 搜索的关键词
      isShowSearchInput: false // 控制搜索框显示隐藏 false/不显示 true/显示
    }
  },
  mounted() {
    new BScroll('.course-content-wrapper', {
      click: true
    })
  },
  methods: {
    /**
     * 控制搜索框显示隐藏
     * @param event
     */
    search(event) {
      this.isShowSearchInput = event
    },
    /**
     * input搜索框的搜索回调
     * @param val
     */
    onSearch(val) {
      console.log(val)
      this.Toast(val)
    },
    /**
     * input搜索框的取消回调
     */
    onCancel() {
      this.isShowSearchInput = false
    }
  }
}
</script>

<style scoped lang="less" rel="stylesheet/less">
@import "../../common/css/mixins.less";

.form-tag {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 10;
}

.course {
  width: 100%;

  .course-content-wrapper {
    position: fixed;
    top: 46px;
    bottom: 0;
    width: 100%;
  }
}
</style>
